home *** CD-ROM | disk | FTP | other *** search
- /*****
- * CGestisciMenu_v003.h
- *
- * Gestisce una risorsa di tipo 'MENU'.
- * © 1994-96 Francesco Cadili.
- *
- ****/
- #ifndef __CGestisciMenu__
- #define __CGestisciMenu__
- #include <Types.h>
- #include <Menus.h>
- #include <Windows.h>
- #include <Dialogs.h>
-
- class CMenuRec
- {
- friend class CGestisciMenu;
- protected:
- MenuHandle menu; // menu pointer
- short menuID; // menu ID
- short fatherMenuID; // the ID of the father
- short fatherItemPos; // the position in the father (v003)
- short menuFlag; // bit (7-0) the position in the menu bar.
- // bit 8 (inMenuBar_mask) if the menu is in the
- // MBAR. (v001)
- // bit 9 (readFromResource_mask) if the menu is
- // read from the resource file (v001).
- // The <menuFlag> replaces the field <inMenuBar>
- // and <readFromResource>. (v002)
- public:
- enum {pos_mask = 0xFF, inMenuBar_mask = 0x100, readFromResource_mask = 0x200};
-
- /*** constructor
- *
- ****/
- CMenuRec(void);
-
- /*** destructor
- *
- ****/
- ~CMenuRec(void);
-
- /*** "Dispose(Boolean delete)
- *
- * Toglie un menu dalla barra dei menu. Il menu viene eliminato
- * dalle risorse se delete è true. (v001)
- *
- * Val OUTPUT: true se errore, false altrimenti.
- *
- ****/
- Boolean Dispose(Boolean del);
-
- /***
- * menuData(&menuHdl, &menuID)
- *
- * Get the data of the choice.
- *
- * Par OUTPUT: <menuHdl> the handle of the menu.
- * <menuID> the ID of the menu.
- *
- ***/
- Boolean menuChoiceData(MenuHandle *menuHdl, short *menuID);
-
- /***
- * Link a submenu to a item in the main menu.
- *
- * Par INPUT: <fatherID> the ID of the main menu,
- * <posInFM> the position in the main menu,
- * <subID> the ID of the submenu,
- * <pos> the position in the subMenu.
- ****/
- Boolean getCurrentPos(short *fatherID, short *posInFM, short *subID);
-
- /***
- * DisegnaItem(theWPtr, menuData);
- *
- * Disegna il campo selezionato dal pop up.
- *
- ****/
- void DrawMenu(WindowPtr theDialog, short itemInDialog, Boolean drawText,
- short itemInMenu);
-
- /***
- * Link a submenu to a item in the main menu.
- *
- * Par INPUT: 'elOrdHdl' the menu data,
- * <fatherID> the ID of the main menu,
- * <fatherItemPos> the position in the main menu,
- * <subMenuID> the ID of the submenu,
- * <subMenu> the subMenu handle,
- * <readFromRes> true if the menu is read from a resource file.
- ****/
- Boolean InsertSubmenu(short fatherID, short fatherItemPos, short subMenuID,
- MenuHandle subMenu, Boolean readFromRes, short subMenuNum);
- };
-
- class CGestisciMenu
- {
- private:
- /*** "InitData_gestMenu(kPopUpID, itemInDialog)"
- *
- * Inizializza i dati relativi al DLOG.
- * (Presuppone che i primi dati della struttura globale
- * siano presenti, strongly modify on v002).
- *
- * Par INPUT: 'textFont' la fonte del campo text edit,
- * 'textHeight' l'altezza del campo text edit.
- * Val OUTPUT: TRUE se errore, FALSE altrimenti.
- *
- ***/
- Boolean InitData(short kPopUpID, short itemInDialog);
-
- /***
- * setDefault_gestMenu();
- *
- * set the default value. (v002)
- *
- ***/
- Boolean setDefault(void);
-
- /***
- * menu = getSubPopUp(item);
- *
- * From version 002 the main menu is in the submenu list, so if NULL is
- * returned an error occurs.
- *
- * Par INPUT: <menuID> the menu ID.
- * Par OUTPUT: <*pos> the position of the menu in the menu array (from 0 to 255)
- * Val OUTPUT: the menu handle of the menu with ID <menuID>.
- ***/
- MenuHandle getSubPopUp(short menuID, short *pos);
-
- /***
- * Link a submenu to a item in the main menu.
- *
- * Par INPUT: 'elOrdHdl' the menu data,
- * <fatherID> the ID of the main menu,
- * <fatherItemPos> the position in the main menu,
- * <subMenuID> the ID of the submenu,
- * <subMenu> the subMenu handle,
- * <readFromRes> true if the menu is read from a resource file.
- ****/
- Boolean InsertSubmenu(short fatherID, short fatherItemPos, short subMenuID,
- MenuHandle menu, Boolean readFromRes);
-
- protected:
- CMenuRec ***subMenu; // The field <kPopUpID>, <popUpMenu>
- // and <inMenuBar> are in **subMenu. (v002)
- DialogPtr theDialog;
-
- public:
- short itemInDialog;
- long lastValore;
- short itemInMenu; // the position of last item chosen.
- short posMenuChosen; // The fields <sceltaPopUp> and <sceltaID>
- // are replaced by <posMenuChosen>. (v002)
-
- /**** constructor();
- *
- ****/
- CGestisciMenu(void);
-
- /****
- * result = Alloca_gestMenu(kPopUpID);
- *
- * Revisoned (use modified SetErrorData)
- *
- * Alloca la struttura dati "gestElOrdRec" nello Heap.
- *
- * Par INPUT: 'kPopUpID' l'ID del Menu.
- * 'itemInDialog' item nel dialog.
- * Val OUTPUT: false se tutto ok, true altrimenti.
- *
- ****/
- Boolean IGestisciMenu(DialogPtr theDialog, short kPopUpID, short itemInDialog);
-
- /*** Dispose()
- *
- * Dealloca la struttura dati.
- * Nota: da chiamare prima della deallocazione del
- * dialog <theDialog>.
- *
- ***/
- void Dispose(void);
-
- /***
- * clickInPopUp(theWPtr, menuData, drawText);
- *
- * Handle a mouse event in the popUp field.
- * Draw a check on the item selected. (v001)
- *
- ****/
- Boolean CGestisciMenu::clickInPopUp(Boolean drawText);
-
- /***
- * Link a submenu to a item in the main menu.
- *
- * Par INPUT: <fatherID> the ID of the main menu,
- * <posInFM> the position in the main menu,
- * <subID> the ID of the submenu,
- * <pos> the position in the subMenu.
- ****/
- Boolean getCurrentPos(short *fatherID, short *posInFM, short *subID,
- short *pos);
-
- /***
- * menuData(&menuHdl, &menuID)
- *
- * Get the data of the choice.
- *
- * Par OUTPUT: <menuHdl> the handle of the menu.
- * <menuID> the ID of the menu.
- *
- ***/
- Boolean menuChoiceData(MenuHandle *menuHdl, short *menuID, short *pos);
-
- /***
- * menuData(&menuHdl, &menuID)
- *
- * Get the data of the menu.
- *
- * Par INPUT: <elOrdHdl> the menu structure.
- * Par OUTPUT: <menuHdl> the handle of the menu.
- * <menuID> the ID of the menu.
- *
- ***/
- Boolean menuData(MenuHandle *menuHdl, short *menuID);
-
- /***
- * DisegnaItem(theWPtr, menuData);
- *
- * Disegna il campo selezionato dal pop up.
- *
- ****/
- void DrawMenu(Boolean drawText);
-
- /***
- *
- * readItemInMenu();
- *
- ***/
- short readItemInMenu(void);
- };
- #endif